//
//  UIButton+RAC.m
//  高仿暴走斗图
//
//  Created by huangsongyao on 16/3/26.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "UIButton+RAC.h"

@implementation UIButton (RAC)

+ (UIButton *)rac_createButtonForBackgroundImage:(UIImage *)image withHighImage:(UIImage *)hImage title:(NSString *)title highTitle:(NSString *)hTitle signalCompletion:(void(^)(id x))completion {
    
    return [[self alloc] initWithRAC_createButtonForBackgroundImage:image
                                                      withHighImage:hImage
                                                              title:title
                                                          highTitle:hTitle
                                                   signalCompletion:completion];
}


- (UIButton *)initWithRAC_createButtonForBackgroundImage:(UIImage *)image withHighImage:(UIImage *)hImage title:(NSString *)title highTitle:(NSString *)hTitle signalCompletion:(void(^)(id x))completion {
    
    UIButton *button = [NSObject createButtonBGImage:image
                                              hImage:hImage
                                               title:title
                                              hTitle:hTitle];
    
    [[[button rac_signalForControlEvents:UIControlEventTouchUpInside] deliverOn:[RACScheduler mainThreadScheduler]] subscribeNext:^(id x) {
        if (completion) {
            completion(x);
        }
    }];
    return button;
}

@end
